﻿//-----------------------------------------------------------------------
// <copyright file="AccountController.cs" company="SLWY Enterprises">
// * Copyright (C) 2017 四川商旅无忧科技有限公司 版权所有。
// * version : 1.0
// * author  : qinchaoyue
// * FileName: AccountController.cs
// * history : created by qinchaoyue 2017-10-16 04:24:29
// </copyright>
//-----------------------------------------------------------------------

using Microsoft.AspNetCore.Mvc;
using Slwy.Application.Dtos;
using Slwy.Application.Interfaces;
using Slwy.Core.Entities;
using Slwy.Mvc.Controller;

namespace WebApplication.Controllers
{
    using System;
    using System.ComponentModel;
    using System.Text;

    using Microsoft.Extensions.Logging;

    using Slwy.Data.Entity.Interfaces;
    using Slwy.FrameCore.Helper;

    /// <summary>
    /// 帐号操作类
    /// </summary>
    [Route("api/test/[controller]")]
    public class AccountController : SlwyController
    {
        //// private readonly DiscoveryHttpClientHandler _discoveryHttpClientHandler;

        private readonly ILogger _logger;

        /// <summary>
        /// accountBll
        /// </summary>
        // private readonly IAccountService _accountBll;

        /// <summary>
        /// The _account info repository.
        /// </summary>
        // private readonly IRepository<AccountInfoEntity, string> _accountInfoRepository;

        private readonly IUserDataService _userDataService;

        /// <summary>
        /// Initializes a new instance of the <see cref="AccountController"/> class. 
        /// 构造函数
        /// 依赖注入元素
        /// </summary>
        /// <param name="accountBll">
        /// the accountBll.
        /// </param>
        /// <param name="accountInfoRepository">
        /// The account Info Repository.
        /// </param>
        /// <param name="slwyHttpClient">
        /// The slwy Http Client.
        /// </param>
        public AccountController(ILogger<AccountController> logger, IUserDataService userDataService)
        {
            this._logger = logger;
            this._userDataService = userDataService;
            // this._accountInfoRepository = accountInfoRepository;
        }

        /// <summary>
        /// 通过使用 sqlsugar 向数据库插入数据.
        /// </summary>
        /// <param name="dto"> the dto.  </param>
        /// <returns> The <see cref="IActionResult"/>.  </returns>
        [HttpPost]
        public IActionResult AddUserInfo([FromBody]UserInfoDto dto)
        {
            this._userDataService.AddUserInfo(dto);
            return this.Ok("success");
        }

        /// <summary>
        /// 通过使用 sqlsugar 查询数据库中的数据
        /// </summary>
        /// <param name="id"> the id.  </param>
        /// <returns> The <see cref="IActionResult"/>.  </returns>
        [HttpGet("ById/{id}")]
        public IActionResult GetUserInfo(string id)
        {
            //var userInfo = this._accountBll.GetUserInfo(id);
            return this.Ok();
        }

        /// <summary>
        /// 通过使用 sqlsugar 查询数据库中的数据
        /// </summary>
        /// <param name="inDto"> the id.  </param>
        /// <returns> The <see cref="IActionResult"/>.  </returns>
        [HttpGet("byaccountid")]
        public IActionResult GetUserInfoByAccountId(ByAccountIdInDto inDto)
        {
            return this.Ok("success");
        }

        /// <summary>
        /// 获取帐号和密码
        /// </summary>
        /// <param name="account">帐号</param>
        /// <returns>帐号和密码</returns>
        [HttpGet("ByAccount/{account}")]
        public IActionResult GetAccount(string account)
        {
            return this.Ok();
        }
    }
}